<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
    <h1>ajax</h1>
    <hr>

    <script>
        var xhr = new XMLHttpRequest();
        console.log(xhr);

        //事件回调
        xhr.onreadystatechange = function () {
            // console.log(xhr.readyState);
            if(xhr.readyState == 4){
                if(xhr.status == 200){
                    //获取相应文本
                    alert(xhr.responseText);
                }
            }
            
        }

        //请求初始化
        xhr.open('get','./php/111.php',true);

        //正式发送
        xhr.send();

        
    </script>
</body>
</html>